"""
ASGI config for basal_adjust project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""

import os
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'basal_adjust.settings')

# 首先实例化默认的ASGI应用
django_asgi_app = get_asgi_application()


from routing import websocket_urlpatterns  # 从根目录下的routing.py导入路由列表

application = ProtocolTypeRouter({
    "http": django_asgi_app,  # 这里保留了原来的HTTP处理
    "websocket": AuthMiddlewareStack(
        URLRouter(
            websocket_urlpatterns  # 使用从routing.py导入的路由列表
        )
    ),
})